#include <hiredis.h>

int main()
{
	struct timeval tv = {1, 0};
	redisContext* pConn = redisConnectWithTimeout("127.0.0.1", 6379, tv);
	redisReply* r = NULL;
/*	
	r = (redisReply*)redisCommand(pConn, "lpush wait_list \"\%s\"", "xuheng");
	if (NULL == r) {
		printf("connection error\n");
	}

	if(r->type == REDIS_REPLY_INTEGER){
		printf("Succeed to execute lpush wait_list [%s].\n", "xuheng");
	}else{
		printf("FAILED to execute lpush wait_list [%s].\n", "xuheng");
	}
	freeReplyObject(r);
*/	
 	r = (redisReply*)redisCommand(pConn, "lpop wait_list");
	if (NULL == r) {
		printf("connection error\n");
	}
	
	char buf[1024]="";
	if(r->type == REDIS_REPLY_STRING){
		strcpy(buf, r->str);
		printf("Succeed to execute lpop wait_list[%s].\n", buf);
	}else{
		printf("FAILED to execute lpop wait_list.\n");
	}
	freeReplyObject(r);
}
